package com.qipay.mapper;

import com.qipay.baas.model.CardBind;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * Creator: Yao
 * Date:    2017/10/18
 * For:
 * Other:
 */
@Mapper
public interface CardBindMapper extends com.qipay.baas.mapper.CardBindMapper {


    @Select({"select * from `card_bind` where `user_id` = #{userId}"})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
            @Result(column="bank", property="bank", jdbcType=JdbcType.VARCHAR),
            @Result(column="sub_bank", property="subBank", jdbcType=JdbcType.VARCHAR),
            @Result(column="card", property="card", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR)
    })
    List<CardBind> listByUserId(@Param("userId") Long userId);

    @Select({"select count(0) from card_bind where user_id = #{userId}"})
    long total(@Param("userId") Integer userId);

    @Select({"select * from `card_bind` where `user_id` = #{userId} limit #{start}, #{offset}"})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
            @Result(column="bank", property="bank", jdbcType=JdbcType.VARCHAR),
            @Result(column="sub_bank", property="subBank", jdbcType=JdbcType.VARCHAR),
            @Result(column="card", property="card", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR)
    })
    List<CardBind> pageByUserId(@Param("userId") int userId, @Param("start") int start, @Param("offset") int size);
}
